croaring-rs
A Rust wrapper for CRoaring (a C/C++ implementation at https://github.com/RoaringBitmap/CRoaring)
The original java version can be found at https://github.com/RoaringBitmap/RoaringBitmap
Bitmap usage example
use Bitmap;
let mut rb1 = create;
rb1.add;
rb1.add;
rb1.add;
rb1.add;
rb1.add;
rb1.add;
rb1.add;
rb1.run_optimize;
let mut rb2 = create;
rb2.add;
rb2.add;
rb2.add;
rb2.run_optimize;
let mut rb3 = create;
assert_eq!;
assert!;
rb1.and_inplace;
rb3.add;
rb3.or_inplace;
let mut rb4 = fast_or;
rb1.and_inplace;
println!;
rb3.add;
rb3.or_inplace;
println!;
rb3.add;
rb3.or_inplace;
println!;
println!;
println!;
rb4 = fast_or;
println!;
For 64bit Bitmap support, checkout the Treemap
. Treemap
is not API-compatible with Bitmap
, yet most the functionality is overlapping.
Treemap usage example
use u64;
use Treemap;
let mut treemap = create;
treemap.add;
treemap.remove;
/// Serialization compatible with croaring Treemap version at https://github.com/RoaringBitmap/CRoaring/blob/b88b002407b42fafaea23ea5009a54a24d1c1ed4/cpp/roaring64map.hh
use NativeSerializer;
let mut treemap1 = create;
for i in 100..1000
treemap1.add;
treemap1.add;
/// Serialization compatible with JVM Treemap version at https://github.com/RoaringBitmap/RoaringBitmap/blob/34654b2d5c3e75e7f9bca1672f4c0b5800d60cf3/roaringbitmap/src/main/java/org/roaringbitmap/longlong/Roaring64NavigableMap.java
use JvmSerializer;
let mut treemap2 = create;
for i in 100..1000
treemap2.add;
treemap2.add;
Building
git clone --recursive https://github.com/saulius/croaring-rs/
cd croaring-rs
cargo build
In croaring-rs
, just like in CRoaring,
some CPU related code optimizations are enabled dynamically at runtime. If you are
building binaries for specific CPU architectures you can specify ROARING_ARCH
environment
variable to control enabled code optimizations, e.g.
ROARING_ARCH=ivybridge cargo build --release
.
C binding generation
Since version 0.7.0
croaring-rs
ships with pre-generated bindings to CRoaring
library
in order to speed up builds and remove the need for a recent clang
version. However
you can revert to old behaviour and generate bindings with bindgen
during build time. In
order to do it please use buildtime_bindgen
feature flag, e.g.:
[dependencies.croaring]
version = "0.7"
features = ["buildtime_bindgen"]
Testing
Running unit tests and doc tests:
cargo test
Running benchmark suite (currently on Rust nightly toolchain only):
cargo bench
Documentation
Current documentation is available at https://docs.rs/croaring/latest/croaring/